package cn.tannn.captcha.api;

import cn.tannn.captcha.sdk.module.CaptchaVO;
import jakarta.servlet.http.HttpServletRequest;

import java.util.Map;

/**
 * 验证码服务
 *
 * @author <a href="https://t.tannn.cn/">tan</a>
 * @version V1.0
 * @date 2024/12/9 11:43
 */
public interface CaptchaService {
    /**
     * 获取算术验证码
     *
     * @return CaptchaVO
     */
    CaptchaVO math(HttpServletRequest request);

    /**
     * 获取算术验证码
     *
     * @param config key键 {@link cn.tannn.captcha.api.config.ConfigKey}
     * @return CaptchaVO
     */
    CaptchaVO math(HttpServletRequest request, Map<String, Integer> config);

    /**
     * 获取算术验证码(绝对值)
     *
     * @return CaptchaVO
     */
    CaptchaVO absMath(HttpServletRequest request);

    /**
     * 获取算术验证码(绝对值)
     *
     * @param config key键 {@link cn.tannn.captcha.api.config.ConfigKey}
     * @return CaptchaVO
     */
    CaptchaVO absMath(HttpServletRequest request, Map<String, Integer> config);

    /**
     * 自定义纯数字的验证码（随机4位数字，可重复）
     *
     * @return CaptchaVO
     */
    CaptchaVO number(HttpServletRequest request);

    /**
     * 自定义纯数字的验证码（随机4位数字，可重复）
     *
     * @param config key键 {@link cn.tannn.captcha.api.config.ConfigKey}
     * @return CaptchaVO
     */
    CaptchaVO number(HttpServletRequest request, Map<String, Integer> config);

    /**
     * 字符-获取线段干扰验证码
     *
     * @return CaptchaVO
     */
    CaptchaVO line(HttpServletRequest request);

    /**
     * 字符-获取线段干扰验证码
     *
     * @param config key键 {@link cn.tannn.captcha.api.config.ConfigKey}
     * @return CaptchaVO
     */
    CaptchaVO line(HttpServletRequest request, Map<String, Integer> config);


    /**
     * 字符-获取圆圈干扰验证码
     *
     * @return CaptchaVO circle
     */
    CaptchaVO circle(HttpServletRequest request);

    /**
     * 字符-获取圆圈干扰验证码
     *
     * @param config key键 {@link cn.tannn.captcha.api.config.ConfigKey}
     * @return CaptchaVO circle
     */
    CaptchaVO circle(HttpServletRequest request, Map<String, Integer> config);

    /**
     * 字符-获取扭曲干扰验证码
     *
     * @return CaptchaVO
     */
    CaptchaVO shear(HttpServletRequest request);


    /**
     * 字符-获取扭曲干扰验证码
     *
     * @param config key键 {@link cn.tannn.captcha.api.config.ConfigKey}
     * @return CaptchaVO
     */
    CaptchaVO shear(HttpServletRequest request, Map<String, Integer> config);

    /**
     * 获取拼图验证码
     *
     * @return CaptchaVO
     */
    CaptchaVO slide(HttpServletRequest request);

    /**
     * 特制异常信息
     */
    void verifyCaptchaJe(String answer, HttpServletRequest request) throws IllegalAccessException;

    /**
     * 验证验证码的正确性
     * <p>  no try 正确 </p>
     *
     * @param answer  用户回答的答案
     * @param request HttpServletRequest
     */
    void verifyCaptcha(String answer, HttpServletRequest request) throws IllegalAccessException;

    /**
     * 验证验证码的正确性
     * <p>  no try 正确 </p>
     *
     * @param answer 用户回答的答案
     * @param ip     ip
     */
    void verifyCaptcha(String answer, String ip) throws IllegalAccessException;

    /**
     * 特制异常信息
     */
    void verifyCaptchaJe(String answer, String ip) throws IllegalAccessException;
}
